package com.baofu.paycore.biz.notice;

import com.system.kafka.clients.ProductService;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;

/**
 * kafka生产者
 *
 * User: xin deng  Date: 16/5/18 ProjectName: paycore Version: 1.0
 */
@Slf4j
public class ProductHandler {

    /**
     * kafka 生产者
     */
    @Setter
    private ProductService productService;

    @Setter
    private String topicName;

    /**
     * 发送kafka消息
     *
     * @param message          消息内容
     */
    public <T> void sendKafkaMsg(T message){
        try {
            log.info("发送kafka消息：{},{}", topicName, message);
            productService.sendMessage(topicName, message);
            log.info("发送kafka消息success");
        } catch (Exception e){
            log.error("发送kafka消息异常：topicName:{},{}",topicName, e);
        }
    }

}
